/**
 * file
 */
package com.tdkj.action.front.member.spaceManagement;

import java.sql.Timestamp;
import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;
import com.tdkj.action.BaseAction;
import com.tdkj.model.enterprisezone.BeanEnterprise;
import com.tdkj.model.enterprisezone.BeanEnterpriseNews;
import com.tdkj.model.enterprisezone.BeanEnterpriseZoneFriendsLink;
import com.tdkj.model.user.BeanUser;
import com.tdkj.service.enterprisezone.IBeanEnterpriseNewsService;
import com.tdkj.service.enterprisezone.IBeanEnterpriseService;
import com.tdkj.util.PublicConfing;

/**

 * FileName:     NewsManagementAction.java

 * @Description: TODO新闻管理

 * All rights Reserved, Designed By ZTE-ITS

 * Copyright:    Copyright(C) 2010-2011

 * Company       天成科技有限公司

 * @author:    李兴建

 * @version    V1.0 

 * Createdate:         2012-5-27 上午11:49:31

 *

 * Modification  History:

 * Date         Author        Version        Discription

 * -----------------------------------------------------------------------------------

 * 2012-5-27       李兴建          1.0             1.0

 * Why & What is modified: <修改原因描述>

 */
public class NewsManagementAction extends BaseAction {
	private List<BeanEnterpriseNews> newsListWithoutExamine;
	private List<BeanEnterpriseNews> newsListWithExamined;
	private List<BeanEnterpriseNews> newsList;
	private IBeanEnterpriseNewsService enterpriseNewsService;
	private IBeanEnterpriseService enterpriseService;
	
	public String execute(){
		BeanUser user =  (BeanUser) ActionContext.getContext().getSession().get(PublicConfing.MEMBER_MEMBWE_OBJ_STRING_CONFIG);
		BeanEnterprise enterprise = user.getEnterprise();
		newsList = enterpriseNewsService.findByProperty("enterprise", enterprise ,BeanEnterpriseNews.class);
		newsListWithoutExamine = enterpriseNewsService.findByProperty("examineState", "未审核", BeanEnterpriseNews.class);
		newsListWithExamined = enterpriseNewsService.findByProperty("examineState", "审核通过", BeanEnterpriseNews.class);
		return "success";
	}
	
	public String update(){
		return execute();
	}
	
	public String delete(){
		Long newsid = Long.valueOf( ServletActionContext.getRequest().getParameter("newsid"));
		BeanEnterpriseNews news = enterpriseNewsService.findById(newsid, BeanEnterpriseNews.class);
		enterpriseNewsService.delete(news);
		return execute();
	}
	
	public List<BeanEnterpriseNews> getNewsListWithoutExamine() {
		return newsListWithoutExamine;
	}

	public void setNewsListWithoutExamine(
			List<BeanEnterpriseNews> newsListWithoutExamine) {
		this.newsListWithoutExamine = newsListWithoutExamine;
	}

	public List<BeanEnterpriseNews> getNewsListWithExamined() {
		return newsListWithExamined;
	}

	public void setNewsListWithExamined(
			List<BeanEnterpriseNews> newsListWithExamined) {
		this.newsListWithExamined = newsListWithExamined;
	}

	public List<BeanEnterpriseNews> getNewsList() {
		return newsList;
	}

	public void setNewsList(List<BeanEnterpriseNews> newsList) {
		this.newsList = newsList;
	}

	@Resource
	public void setEnterpriseNewsService(IBeanEnterpriseNewsService enterpriseNewsService) {
		this.enterpriseNewsService = enterpriseNewsService;
	}
	
	@Resource
	public void setEnterpriseService(IBeanEnterpriseService enterpriseService) {
		this.enterpriseService = enterpriseService;
	}
}
